#version 110

uniform mat4 mat_proj;
uniform mat4 mat_view;
uniform mat4 mat_world;

uniform mat4 mat_bones[32];


attribute vec4 vertex;
attribute vec3 normal;
attribute vec2 tex_coord0;
attribute vec3 bones;
attribute vec3 blends;


varying vec2 fTexCoord0;
varying vec4 color;

struct Light
{
  vec4 position;
  vec4 ambient;
  vec4 diffuse;
  vec4 specular;
  vec3 attenuation;
};

struct Material
{
  vec4  ambient;
  vec4  diffuse;
  vec4  specular;
  float shininess;
  vec4  emission;
};


vec4 calculate_phong_lighting (
                                mat4      mat_world,
                                mat4      mat_view,
                                vec4      lVertex,
                                vec3      lNormal,
                                Light     light,
                                Material  mat
                                );
uniform Light light;
uniform Material mat;
                             

void main ()
{
  int idx = int(bones.x);

  gl_Position = mat_proj * mat_view * mat_world * mat_bones[idx] * vertex;

  color = calculate_phong_lighting (mat_world, mat_view, vertex, normal, light, mat);

  fTexCoord0 = tex_coord0;
}


